<template>
	<basic-container>
		<avue-crud :option="option" :data="data" ref="crud" @expand-change="expandChanges" :table-loading="loading"
		:permission="permissionList" :page="page" @refresh-change="refreshChange" @search-change="searchChange"
		@search-reset="searchReset" :cell-style="cellStyle" @current-change="currentChange" @size-change="sizeChange" @selection-change="selectionChange" @on-load="onLoad">
			<template slot="expand" slot-scope="{row}">
				<avue-crud ref="crud" :option="option1"  v-if="row.orderFormGoodsResultList.length>0"  :data="row.orderFormGoodsResultList"
				:row-style="rowStyle">
					<template slot-scope="{row}" slot="goodsMainPhotoUrl">
						<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
					</template>
					<template slot-scope="{row}" slot="goodsName">
						<div>{{row.goodsName}} <span style="color: red;" v-if="row.acType==8">[赠品]</span></div>
					</template>
				</avue-crud>
				<div v-else class="loading_icon">
					<i class="el-icon-loading"></i>
				</div>
			</template>
			<template slot-scope="scope" slot="menu">
				<el-button type="text" v-if="scope.row.status==0" size="small" @click="shipGoods(scope.row)">发货</el-button>
				<el-button type="text" v-if="scope.row.status==1&&scope.row.choiceType==0" size="small" @click="editLogistics(scope.row)">修改物流</el-button>
				<el-button type="text" size="small" @click="viewOrderDetail(scope.row.id)">查看详情</el-button>
			</template>
			<!-- 自定义添加搜索条件  按日期搜索  -->
			<template slot="search">
				<el-col :md="12" :xs="24" style="float: left;width: 70%;">
					<el-form-item label="下单时间" style="width: 50%;display: inline-block;">
						<el-date-picker size="mini" placeholder="开始时间" @change="getTime(0)" value-format="yyyy-MM-dd HH:mm:ss" v-model="beginTime" type="datetime">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="至" label-width="40px" style="width: 50%;display: inline-block;">
						<el-date-picker size="mini" placeholder="结束日期" @change="getTime(1)" value-format="yyyy-MM-dd HH:mm:ss" v-model="endTime" type="datetime">
						</el-date-picker>
					</el-form-item>
				</el-col>
            </template>
            <template slot="searchMenu">
				<el-button type="primary" size="mini" @click="outCheckExcel">导出勾选</el-button>
                <el-button type="primary" size="mini" @click="outExcel">导出配货单</el-button>
            </template>
		</avue-crud>
		<el-dialog title="请输入物流信息" :visible.sync="sendDialogVisible" width="40%">
			<avue-form ref="optionSend" @resetForm="emptytChange" @submit="sendGoods" :option="optionSend" v-model="formSend">
				<!-- <template slot-scope="scope" slot="menuForm">
					<el-button @click="sendGoods" type="primary" :loading = "isLoad">提交</el-button>
				</template> -->
				<template slot-scope="{row}" slot="distributionSn">
					<div>{{formSend.distributionSn}}</div>
				</template>
				<template slot-scope="{row}" slot="addressMobile">
					<div>{{formSend.addressMobile}}</div>
				</template>
				<template slot-scope="{row}" slot="areaInfo">
					<div>{{formSend.areaInfo}}</div>
				</template>
				<template slot-scope="{row}" slot="trueName">
					<div>{{formSend.trueName}}</div>
				</template>
				<template slot-scope="scope" slot="storeTime">
					<div class="upload">
						<el-date-picker v-model="formSend.storeTime" type="daterange" :picker-options="pickerOptions" range-separator="至"
						start-placeholder="开始日期" end-placeholder="结束日期" align="right" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
						</el-date-picker>
					</div>
				</template>
			</avue-form>
		</el-dialog>
		<el-drawer title="配货单详情" :visible.sync="dialogDeatilVisible" :with-header="true" size="60%">
			<avue-form :option="optionDetail" v-model="form1">
				<template slot="group1Header">
					<h4>订单信息</h4>
				</template>
				<!-- <template slot="group2Header">
					<h4>卖家信息</h4>
				</template> -->
				<template slot="group3Header">
					<h4>配货单信息</h4>
				</template>
				<template slot="group4Header">
					<h4>收货地址</h4>
				</template>
				<template slot="group5Header">
					<h4>门店自提信息</h4>
				</template>
				<template slot-scope="scope" slot="menuForm">
					<el-button @click="closeDetailDialog">关闭</el-button>
				</template>
				<template slot-scope="scope" slot="goodsDetails">
					<avue-crud :data="form1.goodsDetail" :option="option1">
						<template slot-scope="{row}" slot="goodsMainPhotoUrl">
							<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
						</template>
						<template slot-scope="{row}" slot="goodsName">
							<div>{{row.goodsName}} <span style="color: red;" v-if="row.acType==8">[赠品]</span></div>
						</template>
					</avue-crud>
				</template>
				<template  slot-scope="scope" slot="invoiceType">
					<div>
						<p v-if="form1.invoiceType==0">个人</p>
						<p v-if="form1.invoiceType==1">单位</p>
						<p v-if="form1.invoiceType==2">不开发票</p>
					</div>
				</template>
				<template slot-scope="scope" slot="invoiceTitle">
					<p>{{form1.invoiceTitle}}</p>
				</template>
				<template slot-scope="scope" slot="invoiceNum">
					<p>{{form1.invoiceTaxNum}}</p>
				</template>
				<template slot-scope="scope" slot="distributionSn">
					<div class="distribution" v-for="item of form1.orderDistributionList" :key="item.id">
						<el-form :model="item">
							<el-form-item>
								<span style="padding: 0.1rem 0.5rem">配货单号：{{item.distributionSn}}</span>
								<span style="padding: 0.1rem 0.5rem">生成时间：{{item.addTime}}</span>
								<span style="padding: 0.1rem 0.5rem">配货单状态：{{item.status}}</span>
							</el-form-item>
							<el-form-item v-if="item.orderFormGoodsResultList.length>0">
								<avue-crud ref="crud2" :option="option1" :data="item.orderFormGoodsResultList">
									<template slot-scope="{row}" slot="goodsMainPhotoUrl">
										<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
									</template>
									<template slot-scope="{row}" slot="goodsName">
										<div>{{row.goodsName}} <span style="color: red;" v-if="row.acType==8">[赠品]</span></div>
									</template>
								</avue-crud>
							</el-form-item>
							<el-form-item v-else>
								<avue-crud ref="crud2" :option="option1" :data="form1.goodsDetail">
									<template slot-scope="{row}" slot="goodsMainPhotoUrl">
										<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
									</template>
									<template slot-scope="{row}" slot="goodsName">
										<div>{{row.goodsName}} <span style="color: red;" v-if="row.acType==8">[赠品]</span></div>
									</template>
								</avue-crud>
							</el-form-item>
							<el-form-item>
								<p>物流公司：{{item.ecName}}</p>
								<p>物流单号：{{item.shipCode}}</p>
								<el-steps direction="vertical" :active="item.expressInfoBean.data.length">
									<el-step v-for="obj of item.expressInfoBean.data" icon="el-icon-success" :key="obj.index" style="padding: 0.2rem;" :description="obj.time+obj.context"></el-step>
								</el-steps>
							</el-form-item>
						</el-form>
					</div>
				</template>
			</avue-form>
		</el-drawer>
	</basic-container>
</template>

<script>
	import {
		getList,
		sendGoods,
		modifyLogistics,
		getDetail,
		getOrderFormGoods,
		isGoodsChoiceType
	} from "@/api/order/seller/orderDistribution";
	
	import { getStoreWillCallId} from '@/api/order/orderForm';
	import {
		mapGetters
	} from "vuex";
	import {
		testCode,
		validateFormat
	} from '@/util/util';
	import {getToken} from '@/util/store';
	var Dict = JSON.parse(localStorage.getItem("mall-dictionary")).content;
	var orderTypeEnum = Dict.orderTypeEnum;
	Dict.payWayEnum.splice(4, 1);
	Dict.payWayEnum.push({value:5,label:'无'});
	export default {
		data() {
			return {
				idList:[],
				pickerOptions: {
					disabledDate(time) {
						return time.getTime()+ 3600 * 1000 * 24 * 1 < Date.now();
					},
				},
				form1: {},
				formSend: {},
				obj: {},
				query: {},
				beginTime: '',
				endTime: '',
				orderType:"",
				loading: true,
				rolesTree: [],
				rolesKeys: [],
				box: false,
				// isLoad:false,
				dialogDeatilVisible: false,
				sendDialogVisible: false,
				page: {
					pageSize: 10,
					currentPage: 1,
					total: 1,
					pageSizes: [10, 20, 30, 40], //默认
				},
				data: [],
				optionSend: {
					emptyBtn: false,
					submitBtn: true,
					column: [{
							label: "配货单号",
							prop: "distributionSn",
							span: 24,
							formslot:true,
							labelWidth:100,
							readonly: true,
							row: true,
						},{
							label: "收货人手机号",
							labelWidth:100,
							prop: "addressMobile",
							formslot:true,
							span: 24,
							readonly: true,
							row: true,
						},{
							label: "收货地址",
							labelWidth:100,
							type:'textarea',
							prop: "areaInfo",
							formslot:true,
							span: 24,
							readonly: true,
							row: true,
						},{
							label: "收货人姓名",
							prop: "trueName",
							labelWidth:100,
							formslot:true,
							span: 24,
							readonly: true,
							row: true,
						},
						{
							label: "物流公司",
							prop: "ecId",
							type: 'select',
							labelWidth:100,
							span: 24,
							row: true,
							display:true,
							filterable:true,
							dicUrl: "base/expressCompany/listAll",
							props: {
								label: "lable",
								value: "value"
							},
							rules: [{
								required: true,
								message: "请输入物流公司",
								trigger: "blur"
							}]
						},
						{
							label: "物流单号",
							prop: "shipCode",
							span: 24,
							row: true,
							labelWidth:100,
							display:true,
							rules: [{
								required: true,
								message: "请输入物流单号",
								trigger: "blur",
								},{
								validator: validateFormat,
								message:'请输入格式正确的物流单号',
								trigger:'blur'
							}]
						},
						{
							label: "自提时间段",
							prop: "storeTime",
							span: 24,
							row: true,
							display:true,
							labelWidth:100,
							formslot:true,
							rules: [{
								required: true,
								message: "请选择自提时间段",
								trigger: "blur",
							}]
						},
						{
							label: "操作说明",
							prop: "distributionDesc",
							type: 'textarea',
							labelWidth:100,
							span: 24,
							maxlength: 100,
							tip:'100字以内',
							row: true,
						}
					]
				},
				//配货单详情
				optionDetail: {
					submitBtn: false,
					emptyBtn: false,
					group: [{
						prop: 'group1',
						display:true,
						column: [{
							label: '订单编号',
							prop: 'orderId',
							disabled: true,
						}, {
							label: '下单时间',
							prop: 'oPayTime',
							disabled: true,
						}, {
							label: '支付方式',
							prop: 'payWay',
							type: 'select',
							dicData: Dict.payWayEnum,
							disabled: true,
						}]
					}, 
					{
						prop: 'group3',
						column: [{
							label: '配货单号',
							prop: 'distributionSn',
							disabled: true,
						}, {
							label: '生成时间',
							prop: 'addTime',
							disabled: true,
						}, {
							label: '配货单状态',
							row: true,
							prop: 'status',
							disabled: true,
							type: 'select',
							dicData: Dict.orderDistributionStatusEnum,
						}, {
							label: '宝贝详情',
							row: true,
							span: 24,
							prop: 'goodsDetails',
							formslot: true,
						}]
					}, { //收货地址
						prop: 'group4',
						column: [{
							label: '收货人',
							prop: 'trueName',
							disabled: true,
						},{
							label: '电话号码',
							prop: 'mobile',
							disabled: true,
						}, 
						// {
						// 	label: '发票类型',
						// 	display:true,
						// 	prop: 'invoiceType',
						// 	formslot: true,
						// },{
						// 	label: '发票抬头',
						// 	prop: 'invoiceTitle',
						// 	display:true,
						// 	formslot: true,
						// }, {
						// 	label: '纳税人识别号',
						// 	prop: 'invoiceNum',
						// 	labelWidth:120,
						// 	display:true,
						// 	formslot: true,
						// },
						{
							label: '收货地址',
							prop: 'address',
							disabled: true,
						}, {
							label: '详细地址',
							prop: 'areaInfo',
							disabled: true,
							span: 24,
						},  {
							label: '买家留言',
							prop: 'buyerMsg',
							disabled: true,
							span: 24,
						}, ]
					}, {
						prop: 'group5',
						display: false,
						column: [{
							label: '配货单号',
							prop: 'distributionSn',
							disabled: true,
						}, {
							label: '自提时间',
							prop: 'storeWillCallTime',
							disabled: true,
						}, {
							label: '门店信息',
							prop: 'storeWillInfo',
							disabled: true,
						},{
							label: '门店地址',
							prop: 'address',
							disabled: true
						},
						{
							label: '门店电话',
							prop: 'phone',
							disabled: true
						}, {
							label: '操作说明',
							prop: 'text3',
							disabled: true,
						}]
					}]
				},
				//宝贝详情
				option1: {
					border: true,
					header: false,
					menu: false,
					size: 'mini',
					align: 'center',
					menuAlign: 'center',
					column:[{
						label: '宝贝图片',
						prop: 'goodsMainPhotoUrl',
						width: 150,
						slot: true,
					}, {
						label: '宝贝简介',
						align: 'left',
						slot: true,
						prop: 'goodsName'
					}, {
						label: '规格',
						prop: 'specInfo',
					}, {
						label: '单价',
						width: 100,
						prop: 'price'
					}, {
						label: '数量',
						width: 100,
						prop: 'count'
					}]
				},
				option: {
					addBtn: false,
					editBtn: false,
					delBtn: false,
					tip:true,
					selection:true,
					viewBtn: false,
					size: 'mini',
					expand: true,
					expandRowKeys: [],
					align: 'center',
					menuAlign: 'center',
					border: true,
					rowKey: 'distributionSn',
					defaultExpandAll: false,
					height: 'auto',
					// // calcHeight: 380,
					menuWidth: 180,
					search: true,
					searchMenuSpan:6,
					column: [{
							label: "配货单号",
							prop: "distributionSn",
							search: true,
						},
						{
							label: "订单号",
							prop: "orderId",
							search: true,
						},
						{
							label: "收货人电话",
							prop: "addressMobile",
							searchLabelWidth:100,
							search: true,
							width:100,
						},
						{
							label: "收货人姓名",
							prop: "trueName",
							searchLabelWidth:100,
							search: true,
							width:100,
						},
						{
							label: "下单日期",
							prop: "addTime",
							width:140,
						}, {
							label: "实付款(￥)",
							prop: "totalPrice",
							width:100,
						},
						// {
						// 	label: "配货单类型",
						// 	searchLabelWidth: 120,
						// 	prop: "orderType",
						// 	width:100,
						// 	dicData:orderTypeEnum,
						// 	search:true,
						// 	type: 'select',
						// },
						{
							label: "配货单状态",
							searchLabelWidth: 120,
							searchSpan: 6,
							width:90,
							prop: "status",
							type: 'select',
							search: true,
							disabled: true,
							dicData: Dict.orderDistributionStatusEnum,
						}
					]
				},
			};
		},
		watch: {
			'form1.invoiceType'() {//发票类型
				if(this.form1.orderType==1){//普通订单 展示发票
					if (this.form1.invoiceType == 0) { //个人发票
						// this.optionDetail.group[2].column[2].display = true
						// this.optionDetail.group[2].column[3].display = true
						// this.optionDetail.group[2].column[4].display = false
					}else if (this.form1.invoiceType == 2) {//不开发票
						// this.optionDetail.group[2].column[2].display = true
						// this.optionDetail.group[2].column[3].display = false
						// this.optionDetail.group[2].column[4].display = false
					}else if (this.form1.invoiceType == 1){//单位发票
						// this.optionDetail.group[2].column[2].display = true
						// this.optionDetail.group[2].column[3].display = true
						// this.optionDetail.group[2].column[4].display = true
					}
				}else{//积分订单 不展示 发票相关
					// this.optionDetail.group[2].column[2].display = false
					// this.optionDetail.group[2].column[3].display = false
					// this.optionDetail.group[2].column[4].display = false
				}
				
			},
		},
		computed: {
			...mapGetters(["permission", 'userInfo']),
			permissionList() {
				return {

				};
			},
		},
		created() {
			let orderStatusEnum=[];//订单枚举
			//判断当前用户是否包含积分卖家角色
			if(this.userInfo.roleIds.indexOf(6)!=-1){
				let statusEnum=Dict.orderDistributionStatusEnum;
				for(let i=0;i<statusEnum.length;i++){
					if(statusEnum[i].label!="已退款" && statusEnum[i].label!="退款审核"){
						orderStatusEnum.push(statusEnum[i])
					}
				}
				this.option.column[6].dicData=orderStatusEnum;
				this.option.column[3].label="实付积分";

			}else{
				this.option.column[6].dicData=Dict.orderDistributionStatusEnum;
			}
		},
		methods: {
			outExcel(){
				let token = getToken();
				let distributionSn = this.query.distributionSn === undefined ? "" : this.query.distributionSn;
				let orderId = this.query.orderId === undefined ? "" : this.query.orderId;
				let status = this.query.status === undefined ? "" : this.query.status;
				let beginTime = this.query.beginTime === undefined ? "" : this.query.beginTime;
				let endTime = this.query.endTime === undefined ? "" : this.query.endTime;
				let addressMobile = this.query.addressMobile === undefined ? "" : this.query.addressMobile;
				window.location.href = '/order/sellerOrderDistribution/outExcel?token=' + token + '&distributionSn=' +
						distributionSn + '&orderId=' + orderId + '&status=' + status +
						'&beginTime=' + beginTime + '&endTime=' + endTime + '&addressMobile=' + addressMobile;
			},
			outCheckExcel(){
				if (this.idList.length>0){
				let token = getToken();
				let distributionSn = this.query.distributionSn === undefined ? "" : this.query.distributionSn;
				let orderId = this.query.orderId === undefined ? "" : this.query.orderId;
				let status = this.query.status === undefined ? "" : this.query.status;
				let beginTime = this.query.beginTime === undefined ? "" : this.query.beginTime;
				let endTime = this.query.endTime === undefined ? "" : this.query.endTime;
				let addressMobile = this.query.addressMobile === undefined ? "" : this.query.addressMobile;
				let idList=this.idList;
				window.location.href = '/order/sellerOrderDistribution/outExcel?token=' + token + '&distributionSn=' +
						distributionSn + '&orderId=' + orderId + '&status=' + status +
						'&beginTime=' + beginTime + '&endTime=' + endTime + '&addressMobile=' + addressMobile+'&idList='+idList;
				}else {
					this.$message({
						type: "error",
						message: "请勾选一项数据！"
					});
				}
			},
			getTime(type) {
				if(this.beginTime&&type==1){//先输入开始时间 后输入结束时间
					if (this.beginTime > this.endTime) {
						this.$message({
							type: "error",
							message: "结束时间不能小于开始时间"
						});
						this.endTime = ''
					}
				}else if(this.endTime&&type==0){//先输入结束时间 后输入开始时间
					if (this.beginTime > this.endTime) {
						this.$message({
							type: "error",
							message: "开始时间不能大于结束时间"
						});
						this.beginTime = ''
					}
				}
			},
			closeDetailDialog() {
				this.dialogDeatilVisible = false
			},
			emptytChange() {
				this.formSend = {}
			},
			//发货
			shipGoods(row) {
				if(row.expressType){//自提
					this.optionSend.column[1].display=false
					this.optionSend.column[2].display=false
					this.optionSend.column[3].display=false
					this.optionSend.column[4].display=false
					this.optionSend.column[5].display=false
					this.optionSend.column[6].display=true
				}else{
					this.optionSend.column[1].display=true
					this.optionSend.column[2].display=true
					this.optionSend.column[3].display=true
					this.optionSend.column[4].display=true
					this.optionSend.column[5].display=true
					this.optionSend.column[6].display=false
				}
				this.formSend.storeTime = []
				if(row.storeWillCallBeginTime && row. storeWillCallEndTime){
					this.formSend.storeTime.push(row.storeWillCallBeginTime)
					this.formSend.storeTime.push(row. storeWillCallEndTime)
				}
				this.formSend.distributionSn = ""
				this.formSend.distributionId = row.id
				this.formSend.distributionSn = row.distributionSn
				this.formSend.addressMobile = row.addressMobile
				this.formSend.trueName = row.trueName
				this.formSend.areaInfo =row.provinceAreaName + row.cityAreaName + row.countyAreaName + row.areaInfo
				this.formSend.distributionDesc = "";
				this.formSend.shipCode = "";
				this.formSend.ecId = "";
				isGoodsChoiceType( row.goodsIds).then(res=>{
					if(res.data.code==200){
						if(res.data.data){//虚拟商品 直接发货
							sendGoods(this.formSend).then((res) => {
								if(res.data.code==200){
									this.$message.success("发货成功!");
								}else{
									this.$message.error(res.data.message);
								}
								this.onLoad(this.page);
								this.sendDialogVisible = false
								this.emptytChange()
							}, error => {
								console.log(error)
							});
						}else{
							// this.isLoad = false
							this.sendDialogVisible = true
						}
					}
				})
				
			},
			//确认发货
			sendGoods(form,done) {
				this.formSend.ecName = this.formSend.$ecId || ''
				if(this.formSend.storeTime.length>0){
					this.formSend.storeWillCallBeginTime= this.formSend.storeTime [0]
					this.formSend.storeWillCallEndTime= this.formSend.storeTime [1]
				}

				if (this.formSend.orderFormId) {
					modifyLogistics(this.formSend).then((res) => {
						//this.onLoad(this.page);
						if(res.data.code==200){
							this.onLoad(this.page);
							this.$message.success("修改成功!");
						}else{
							this.$message.error(res.data.message);
						}
						done()
						this.sendDialogVisible = false
					}, error => {
						console.log(error)
					});
				} else {
					if(this.formSend.shipCode){
						if(this.formSend.shipCode.length>32){
							done();
							return this.$message.error("请输入正确的物流单号");
						}
					}
					sendGoods(this.formSend).then((res) => {
						if(res.data.code==200){
							this.$message.success("发货成功!");
						}else{
							this.$message.error(res.data.message);
						}
						done()
						this.onLoad(this.page);
						this.sendDialogVisible = false
						this.emptytChange()
					}, error => {
						console.log(error)
					});
				}
				this.option.expandRowKeys=[]
			},
			//修改物流
			editLogistics(row) {
				if(row.expressType){//自提
					this.optionSend.column[1].display=false
					this.optionSend.column[2].display=false
					this.optionSend.column[3].display=false
					this.optionSend.column[4].display=false
					this.optionSend.column[5].display=false
					this.optionSend.column[6].display=true
				}else{
					this.optionSend.column[1].display=true
					this.optionSend.column[2].display=true
					this.optionSend.column[3].display=true
					this.optionSend.column[4].display=true
					this.optionSend.column[5].display=true
					this.optionSend.column[6].display=false
				}
				this.formSend.storeTime = []
				if(row.storeWillCallBeginTime && row. storeWillCallEndTime){
					this.formSend.storeTime.push(row.storeWillCallBeginTime)
					this.formSend.storeTime.push(row. storeWillCallEndTime)
				}
				console.log(row)
				this.isLoad = false
				this.formSend.distributionSn = ""
				this.formSend.distributionId = row.id
				this.formSend.id = row.id
				this.formSend.distributionSn = row.distributionSn
				this.formSend.orderFormId = row.orderFormId
				this.formSend.ecId = row.ecId
				this.formSend.ecName = row.ecName
				this.formSend.shipCode = row.shipCode
				this.formSend.addressMobile = row.addressMobile
				this.formSend.trueName = row.trueName
				this.formSend.areaInfo =row.provinceAreaName + row.cityAreaName + row.countyAreaName + row.areaInfo
				this.formSend.distributionDesc = row.distributionDesc
				isGoodsChoiceType( row.goodsIds).then(res=>{
					if(res.data.code==200){
						if(res.data.data){//虚拟商品 直接发货
							this.$message.warning("虚拟商品无法修改物流!");
						}else{
							// this.isLoad = false
							this.sendDialogVisible = true
						}
					}
				})
				console.log("修改物流",this.formSend)
			},
			//查看详情
			viewOrderDetail(id) {
				//查看详情
				getDetail(id).then((res) => {
					if (res.data.code != 200) {
						return;
					}
					var data = res.data.data
					this.form1.orderId = data.orderForm.orderId
					this.form1.oPayTime = data.orderForm.addTime
					this.form1.payWay = data.orderForm.payWay
					// this.form1.storeName = data.orderForm.storeName
					// this.form1.sellerPhoneNumber = data.orderForm.sellerPhoneNumber
					// this.form1.sellerAddress = data.orderForm.sellerAddress
					this.form1.orderDistributionList = data.orderDistributionList
					this.form1.distributionSn = data.orderDistribution.distributionSn
					this.form1.addTime = data.orderDistribution.addTime
					this.form1.status = data.orderDistribution.status
					this.form1.orderType = data.orderDistribution.orderType
					this.form1.goodsDetail = data.orderDistribution.orderFormGoodsResultList
					this.form1.trueName = data.orderAddressList.trueName
					// this.form1.zip = data.orderAddressList.zip
					this.form1.invoiceType = data.orderFormInfo.invoiceType
					this.form1.invoiceTitle = data.orderFormInfo.invoiceTitle
					this.form1.invoiceTaxNum = data.orderFormInfo.invoiceTaxNum
					this.form1.buyerMsg = data.orderFormInfo.buyerMsg
					this.form1.expressType = data.orderFormInfo.expressType
					this.form1.expressCompanyName = data.orderFormInfo.expressCompanyName
					this.form1.expressCompanyId = data.orderFormInfo.expressCompanyId
					this.form1.address = data.orderAddressList.provinceAreaName + data.orderAddressList.cityAreaName + data.orderAddressList
						.countyAreaName
					this.form1.areaInfo = data.orderAddressList.areaInfo
					this.form1.mobile = data.orderAddressList.mobile
					this.form1.totalPrice = data.orderForm.totalPrice //订单总价
					if(data.orderForm.storeWillCallId){
						getStoreWillCallId(data.orderForm.storeWillCallId).then(res1=>{
							this.form1.phone = res1.data.data.phone
							this.form1.storeWillInfo = res1.data.data.storeName
							this.form1.address = res1.data.data.address
						})
					}
					//门店自提时间 
					if(this.form1.expressType ==0 ){//自提
						this.optionDetail.group[2].display=false
						this.optionDetail.group[3].display=true
					}else{
						this.optionDetail.group[2].display=true
						this.optionDetail.group[3].display=false
					}
					this.form1.storeWillCallTime = data.orderDistribution.storeWillCallBeginTime.split(" ",1) +" -- "+ data.orderDistribution.storeWillCallEndTime.split(" ",1)
					this.form1.text3 = data.orderDistribution.distributionDesc || ' '

				});
				this.dialogDeatilVisible = true
			},
			rowStyle() {
				return {
					backgroundColor: '#f3f3f3',
					color: '#333333'
				}
			},
			cellStyle({row,column,rowIndex,columnIndex}){
				if(columnIndex==8){
					if(row.status==0){
						return {
			              color:'red',
			            }
					}
				}
			},
			expandChanges(row, expendList) {
				if(row.orderFormGoodsResultList){
					return;
				}
				let obj ={
					distributionId:row.id
				}
				getOrderFormGoods(obj).then((res) => {
					if(res.data.code==200){
						row.orderFormGoodsResultList = res.data.data;
					}else{
						this.$message.error(res.data.message);
					}
				});
			},
			searchReset() {
				this.query = {};
				this.beginTime = '';
				this.endTime = '';
				this.onLoad(this.page);
			},
			searchChange(params,done) {
				this.page.currentPage = 1
				params.beginTime = this.beginTime
				params.endTime = this.endTime
				this.option.expandRowKeys=[]
				this.query = params;
				this.onLoad(this.page, params,done);
			},
			currentChange(currentPage) {
				this.page.currentPage = currentPage;
			},
			sizeChange(pageSize) {
				this.page.pageSize = pageSize;
			},
			refreshChange() {
				this.option.expandRowKeys=[]
				this.onLoad(this.page);
			},
			selectionChange(list) {
				let idList = []
				if (list.length > 0) {
					for (let item of list) {
						idList.push(item.id)
					}
					console.log(idList)
					this.idList = idList
				} else {
					this.idList = [];
				}
			},
			onload(val) {
				console.log(val)
			},
			onLoad(page, params = {},done) {
				this.loading = true;
				getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
					if(done){
						done();
					}
					this.loading = false;
					const data = res.data;
					this.page.total = data.count;
					this.data = data.data;
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	.el-col {
		float: none;
		display: inline-block;
		width: auto;
	}
	.loading_icon {
		width:30px;
		margin:auto;
	}
</style>
